<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ page import="cn.ac.cintcm.sh.service.*,cn.ac.cintcm.sh.domain.*,java.net.URLDecoder"%> 
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <title>单方剂寒热分析</title>
    
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<!--
	<link rel="stylesheet" type="text/css" href="styles.css">
	-->
		<link rel="StyleSheet" href="js/dtree.css" type="text/css" />
		<script type="text/javascript" src="js/dtree.js"></script>
<script language=javascript>
	function changeView(o, id, s) {
	    if (id != -1) {
			document.location.href = "./prHCAnalyzeOne.jsp?fjId="+id+"&viewId="+o;
		} else {
			document.location.href = "./prHCAnalyzeOne.jsp?s="+encodeURI(encodeURI(s))+"&viewId="+o;
		}
	}
</script>
  </head>
  <%
  ViewService viewService = new ViewService();
   %>
  <body>
	<table width="100%" border="0">
	  <tr>
	    <td>
	    <%
	    String fjid = request.getParameter("fjId");
	     String pstr = request.getParameter("s");
	     if (pstr != null) {
	     	pstr = URLDecoder.decode(pstr, "UTF-8");
	     }
	    int pId = -1;
	    if (fjid != null) {
	    	pId = Integer.parseInt(fjid);
	    }
	    String viewIdTem = request.getParameter("viewId");
	    int viewId = -1;
	    if(viewIdTem != null && ! viewIdTem.equals("")) {
	        viewId = Integer.parseInt(viewIdTem);
	        request.getSession().setAttribute("view", viewIdTem);
	    } else {
	        viewIdTem = (String) request.getSession().getAttribute("view");
	        if (viewIdTem != null && ! viewIdTem.equals("")) {
	        	viewId = Integer.parseInt(viewIdTem);
	        }
	    }
	   	Iterator  iterator = viewService.getViews().iterator();
	   	if(iterator.hasNext()){
	   	View v = (View)iterator.next();
	   	if(viewId == -1) {
	   		viewId = v.getId();
	   	}
	   	
	     %>
	     <select name="select" onChange="changeView(this.options[this.options.selectedIndex].value,<%=pId%>, '<%=pstr%>');">
	      <option value="<%=v.getId() %>" <%=viewId==v.getId()?"selected":""%>><%=v.getName() %></option>
	      <%} %>
	      <%
	     	while(iterator.hasNext()){
	     		View v = (View)iterator.next();
	     %>
	      <option value="<%=v.getId() %>" <%=viewId==v.getId()?"selected":""%>><%=v.getName() %></option>
	      <%} %> 
	    </select>
	    </td>
	  </tr>
	</table>
	 <%
	   
	    
	    PrescriptionService prescriptionService = new PrescriptionService();
	    String treeStr = "";
	    if (pstr != null && !pstr.trim().equals("")) {
	    	treeStr = prescriptionService.getHCAnalysis(pstr, viewId);
	    } else if (pId != -1) {
	        treeStr = prescriptionService.getHCAnalysis(pId,viewId);
	    }
	     %>
<script language=javascript>
	var d= new dTree("d");
	<%=treeStr %>

</script>

		<div class="content">
			<a href="javascript: d.openAll();">全部打开</a> | <a href="javascript: d.closeAll();">全部折叠</a>
			<p><script>document.write(d);</script></p>
		</div>


   </body>
</html>
